package io.mvvm.bio;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * @program: Netty
 * @description: Bio 客户端
 * @author: 潘
 * @create: 2021-01-17 19:19
 **/
public class BioClient {
    public static void main(String[] args) {
        // 通过构造函数创建Socket，并且连接指定地址和端口的服务端
        try {
            Socket socket = new Socket("127.0.0.1", 6666);

            PrintWriter pw = null;
            // 写数据到服务端
            while (true) {
                pw = new PrintWriter(socket.getOutputStream());
                System.out.print("请输入需要发送的内容：");
                pw.println(new Scanner(System.in).next());
                pw.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
